package com.yunyao.web.controller;

import com.yunyao.common.dto.project.ProjectDto;
import com.yunyao.common.web.util.PageResult;
import com.yunyao.common.web.util.YResult;
import com.yunyao.framework.dto.posyupply.PoSosyupplySaveDto;
import com.yunyao.framework.dto.project.ProjectSaveDto;
import com.yunyao.framework.service.ProjectService;
import com.yunyao.framework.vo.posupply.PoSyupplyinfoVO;
import com.yunyao.framework.vo.project.ProjectInfoVO;
import com.yunyao.framework.vo.project.ProjectVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author xingjishuai
 * @date 2024-07-16
 */
@RestController
@RequestMapping("/project")
public class ProjectController {

    @Autowired
    private ProjectService projectService;

    @GetMapping("/list")
    public YResult<PageResult<ProjectVO>> list(ProjectDto projectDto) {
        return projectService.pageList(projectDto);
    }

    @GetMapping("/info")
    public YResult<ProjectInfoVO> getInfo(String id) {
        return projectService.getProjectById(id);
    }

    @PostMapping("/delete")
    public YResult<Boolean> deleteInfo(@RequestBody ProjectSaveDto saveDto) {
        return projectService.deleteInfo(saveDto.getId());
    }

    @PostMapping("/update")
    public YResult<String> saveInfo(@RequestBody ProjectSaveDto saveDto) {
        return projectService.saveInfo(saveDto);
    }
}
